package controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import action.BoardAddAction;
import action.BoardDeleteAction;
import action.BoardDetailAction;
import action.BoardListAction;
import action.BoardModifyAction;
import action.BoardReplyAction;
import action.BoardReplyView;

@WebServlet("*.bo")
public class BoardController extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public BoardController() {
        super();
    }//boardController

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}//doget

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String reqUri = request.getRequestURI();
		String contPath = request.getContextPath();
		String cmd = reqUri.substring(contPath.length());
		
		if(cmd.equals("/add.bo")){
			BoardAddAction add = new BoardAddAction();
			add.execute(request, response);
		}else if(cmd.equals("/list.bo")){
			BoardListAction list = new BoardListAction();
			list.execute(request, response);
		}else if(cmd.equals("/detail.bo")){
			BoardDetailAction detail = new BoardDetailAction();
			detail.execute(request, response);
		}else if(cmd.equals("/modify.bo")){
			BoardModifyAction modify = new BoardModifyAction();
			modify.execute(request, response);
		}else if(cmd.equals("/delete.bo")){
			BoardDeleteAction delete = new BoardDeleteAction();
			delete.execute(request, response);
		}else if(cmd.equals("/replyview.bo")){
			BoardReplyView repview = new BoardReplyView();
			repview.execute(request, response);
		}else if(cmd.equals("/reply.bo")){
			BoardReplyAction reply = new BoardReplyAction();
			reply.execute(request, response);
		}
	}//dopost
}//class
